#include<iostream>
#include<string>

using namespace std;

class Solution {
public:
    string addStrings(string num1, string num2) {
        int end1 = num1.size() - 1;
        int end2 = num2.size() - 1;
        int add = 0;
        string tmp = "";
        while (end1 >= 0 || end2 >= 0)
        {
            int t1 = end1 >= 0 ? num1[end1--] - '0' : 0;
            int t2 = end2 >= 0 ? num2[end2--] - '0' : 0;
            int result = t1 + t2 + add;
            tmp.push_back('0' + result % 10);
            add = result / 10;

        }

        if (add != 0)
        {
            tmp.push_back('0' + add);
        }

        reverse(tmp.begin(), tmp.end());

        return tmp;

    }
};